package com.work.straighttalk.recevier;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.hyphenate.util.EMLog;
import com.work.straighttalk.VideoCallActivity;
import com.work.straighttalk.ui.VoiceCallActivity;

/**
 * Created by dllo on 16/3/11.
 */
public class CallReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        //拨打方username
        String from = intent.getStringExtra("from");
        Log.d("CallReceiver", from);
        //call type
        String type = intent.getStringExtra("type");
        if("video".equals(type)){ //视频通话
            context.startActivity(new Intent(context, VideoCallActivity.class).
                    putExtra("username", from).putExtra("isComingCall", true).
                    addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }else { //音频通话
            Log.d("CallReceiver", "sjnjgng");
            context.startActivity(new Intent(context, VoiceCallActivity.class).
                    putExtra("username", from).putExtra("isComingCall", true).
                    addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }
        EMLog.d("CallReceiver", "app received a incoming call");
    }
}